<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var p = {
      _name: "大漂亮",//存放数据
      // name //访问数据
      get name () {
        console.log('获取name属性');
        return this._name;
      },
      set name (val) {
        console.log('设置name属性');
        this._name = val;
      }
    }
    console.log(p.name);
    p.name = "鹰酱"
  </script>
</body>

</html>